﻿package com.wandian.util.loader
{
	import com.wandian.data.GameData;

	import flash.display.Loader;
	import flash.display.LoaderInfo;
	import flash.events.Event;
	import flash.events.EventDispatcher;
	import flash.events.IOErrorEvent;
	import flash.events.ProgressEvent;
	import flash.events.SecurityErrorEvent;
	import flash.net.URLRequest;
	import flash.system.ApplicationDomain;
	import flash.system.LoaderContext;
	/**   
	* @author long
	* @QQ 108232706
	* @version 1.0   
	*/   
	public class CLZLoadSWF extends EventDispatcher
	{
		private var m_loadinfo:LoaderInfo;

		public function CLZLoadSWF()
		{
			return;
		}

		public function get loadinfo():LoaderInfo
		{
			return this.m_loadinfo;
		}

		public function Load(param1:String):void
		{
			var _loc_2:*=new Loader();
			var _loc_3:*=new LoaderContext();
			_loc_3.applicationDomain=new ApplicationDomain(ApplicationDomain.currentDomain);
			this.InitLoadEvent(_loc_2.contentLoaderInfo);
			_loc_2.load(new URLRequest(param1), _loc_3);
			return;
		}

		private function InitLoadEvent(param1:LoaderInfo):void
		{
			param1.addEventListener(ProgressEvent.PROGRESS, this.onProgress);
			param1.addEventListener(Event.COMPLETE, this.onComplete);
			param1.addEventListener(IOErrorEvent.IO_ERROR, this.onError);
			param1.addEventListener(SecurityErrorEvent.SECURITY_ERROR, this.onError);
			return;
		}

		private function RemoveLoadEvent(param1:LoaderInfo):void
		{
			param1.removeEventListener(Event.COMPLETE, this.onComplete);
			param1.removeEventListener(ProgressEvent.PROGRESS, this.onProgress);
			param1.removeEventListener(IOErrorEvent.IO_ERROR, this.onError);
			param1.removeEventListener(SecurityErrorEvent.SECURITY_ERROR, this.onError);
			return;
		}

		private function onComplete(event:Event):void
		{
			var _loc_2:*=event.currentTarget as LoaderInfo;
			this.RemoveLoadEvent(_loc_2);
			GameData.domainArr.push(_loc_2.applicationDomain);
			this.dispatchEvent(event);
			return;
		}

		private function onProgress(event:ProgressEvent):void
		{
			this.dispatchEvent(event);
			return;
		}

		private function onError(event:Event):void
		{
			this.dispatchEvent(event);
			return;
		}

	}
}
